//载入基础页面
{extend name="common/base" /}

//页面单独CSS
{block name="CustomCSS"}

{/block}

//页面单独JS
{block name="CustomJS"}
<script src="__STATIC__/vendors/js/jquery.form/jquery.form.min.js"></script>
<script src="__STATIC__/vendors/js/noty/noty.min.js"></script>
<script type="text/javascript">
	$(document).ready(function () {
        $("#ajaxForm").ajaxForm({
            //定义返回JSON数据，还包括xml和script格式
            dataType: 'json',
			//在发送之前进行的操作，如果有问题，返回false即可不会进行提交
            beforeSend: function () {
            	//定义 form为当前表格
                const form = $("#ajaxForm")

				//如果没有完成校验就返回false不提交
				if (form[0].checkValidity() === false){
					return false;
				}
            },
            success: function (data) {
                //提交成功后调用
                new Noty({
		            type: "success",
		            layout: "topRight",
		            text: "成功新增一条数据，ID为" + data,
		            progressBar: true,
		            timeout: 2500,
		            animation: {
		                open: "animated bounceInRight",
		                close: "animated bounceOutRight"
		            },
		            callbacks: {
		            	afterShow: function() {
		            		$(location).attr('href', '{:url('index/index')}');
		            	},
		            }
		        }).show();
                return false;
            },
            error: function(XmlHttpRequest, textStatus, errorThrown){  
                //提交成功后调用
                new Noty({
		            type: "error",
		            layout: "topRight",
		            text: "数据添加失败",
		            progressBar: true,
		            timeout: 2500,
		            animation: {
		                open: "animated bounceInRight",
		                close: "animated bounceOutRight"
		            }
		        }).show();
		        return false;
            } 
        });
	});
</script>
{/block}

//页面名称
{block name="PageName"}
用户信息
{/block}


//自定义Modal
{block name="Modal"}
{/block}

//主页面
{block name="main"}
 <div class="row flex-row">
    <div class="col-xl-12 col-12">
        <div class="widget has-shadow">
            <div class="widget-header bordered no-actions d-flex align-items-center">
                <h4>修改用户信息</h4>
            </div>
            <div class="widget-body">
                <form class="needs-validation" novalidate="" id="ajaxForm" action="{:url('profile/update',['id' => $userData.id])}">
                    <div class="form-group row d-flex align-items-center mb-5">
                        <label class="col-lg-2 form-control-label d-flex justify-content-lg-end">名称</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" placeholder="请输入用户名称" name="name" value="{$userData.name}">
                        </div>
                    </div>
                    <div class="form-group row d-flex align-items-center mb-5">
                        <label class="col-lg-2 form-control-label d-flex justify-content-lg-end">电话</label>
                        <div class="col-lg-6">
                            <input type="phone" class="form-control" placeholder="请输入用户的电话" name="phone" value="{$userData.phone}">
                        </div>
                    </div>
                    <div class="form-group row d-flex align-items-center mb-5">
                        <label class="col-lg-2 form-control-label d-flex justify-content-lg-end">输入新密码</label>
                        <div class="col-lg-6">
                            <input type="password" class="form-control" placeholder="请输入新密码" name="password">
                        </div>
                    </div>
	                <div class="text-right">
	                    <button class="btn btn-gradient-01" type="submit">确认</button>
	                    <button class="btn btn-shadow" type="reset" onclick="history.go(-1);">取消</button>
	                </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}

